import {REACT_TEXT} from "./constans";

/**
 * 把元素几点进行包装
 * 如果虚拟DOM是文本或者数字，包装成一虚拟DOM节点对象
 *
 * @param element 虚拟DOM
 * @returns {{type: symbol, props: {content: (string|number)}}|*}
 */
export function wrapToVodm(element) {
    return typeof element === "string" || typeof element === 'number' ?
        {
            type: REACT_TEXT,
            props:  {
                content: element
            }
        } : element
}